package com.databinding.jetpacktesting

import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent

/**
 * Created by harisucici on 2020/3/9
 * Class description:
 */
class LifeObserver(var myViewModel: MyViewModel) : LifecycleObserver {
    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    fun onCreat() {
        Log.e(TAG, "creaaaaaat")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    fun onResume() {
        Log.e(TAG, "resummmmme")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
    fun onPause() {
        myViewModel.save()
        Log.e(TAG, "pauuuuuuuse")
    }

    companion object {
        private const val TAG = "LifeObserver"
    }

}